package com.xywy.beautyand.ACT;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.xywy.beautyand.MyApplication;
import com.xywy.beautyand.R;
import com.xywy.beautyand.fragment.SumQuestionTypeFrag;

/**
 * *****************************************
 * 
 * @Title: MySeekFrameAct.java
 * @Package com.xywy.bloodandroid.act
 * @Description: TODO(我的咨询)
 * @author smz
 * @date 2015-1-5 上午11:21:27
 * @version V1.0
 ******************************************* 
 */
public class MySeekFrameAct extends FragmentActivity implements OnClickListener {
	private FragmentTransaction fragmentTransaction;
	private FragmentManager fm;
	private LinearLayout question_sum_lin;
	private TextView question_sum_text;
	private LinearLayout not_sovle_lin;
	private TextView not_sovle_text;
	private LinearLayout is_solved_lin;
	private TextView is_solved_text;
	private SumQuestionTypeFrag questionTypeFrag;
	private RelativeLayout left_img;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.act_my_seek);
		initview();
		fm = getSupportFragmentManager();
		initclick();
//		switchFragment(R.id.question_sum_lin);
		MyApplication.getInstance().addActivity(this);
	}

	private void initview() {
		left_img = (RelativeLayout) findViewById(R.id.left_img);
		TextView middle_title=(TextView) findViewById(R.id.middle_title);
		middle_title.setText("我的咨询");
		
		question_sum_lin = (LinearLayout) findViewById(R.id.question_sum_lin);
		question_sum_text = (TextView) findViewById(R.id.question_sum_text);

		not_sovle_lin = (LinearLayout) findViewById(R.id.not_sovle_lin);
		not_sovle_text = (TextView) findViewById(R.id.not_sovle_text);

		is_solved_lin = (LinearLayout) findViewById(R.id.is_solved_lin);
		is_solved_text = (TextView) findViewById(R.id.is_solved_text);
		
	}

	private void initclick() {
	    left_img.setOnClickListener(this);
		question_sum_lin.setOnClickListener(this);
		not_sovle_lin.setOnClickListener(this);
		is_solved_lin.setOnClickListener(this);
	}

	private void switchFragment(int id) {
		fragmentTransaction = fm.beginTransaction();
		//
		hideFragments(fragmentTransaction);
		int fragement_textcolor_press = getResources().getColor(
				R.color.fragement_text_press);
		int fragement_textcolor_normal = getResources().getColor(
				R.color.fragement_text_normal);
		switch (id) {
		case R.id.question_sum_lin:

			question_sum_text.setTextColor(fragement_textcolor_press);

			not_sovle_text.setTextColor(fragement_textcolor_normal);

			is_solved_text.setTextColor(fragement_textcolor_normal);

			if (questionTypeFrag == null) {
				questionTypeFrag = new SumQuestionTypeFrag();
				fragmentTransaction.add(R.id.content_frame, questionTypeFrag);
			} else {
				fragmentTransaction.show(questionTypeFrag);
			}

			break;
		case R.id.not_sovle_lin:

			question_sum_text.setTextColor(fragement_textcolor_normal);
			not_sovle_text.setTextColor(fragement_textcolor_press);

			is_solved_text.setTextColor(fragement_textcolor_normal);

			if (questionTypeFrag == null) {
				questionTypeFrag = new SumQuestionTypeFrag();
				fragmentTransaction.add(R.id.content_frame, questionTypeFrag);
			} else {
				fragmentTransaction.show(questionTypeFrag);
			}
			break;

		case R.id.is_solved_lin:

			question_sum_text.setTextColor(fragement_textcolor_normal);
			not_sovle_text.setTextColor(fragement_textcolor_normal);

			is_solved_text.setTextColor(fragement_textcolor_press);
			if (questionTypeFrag == null) {
				questionTypeFrag = new SumQuestionTypeFrag();
				fragmentTransaction.add(R.id.content_frame, questionTypeFrag);
			} else {
				fragmentTransaction.show(questionTypeFrag);
			}
			break;
		}
		fragmentTransaction.commit();
	}

	private void hideFragments(FragmentTransaction ft) {
		if (questionTypeFrag != null) {
			ft.hide(questionTypeFrag);
		}
//		if (doctorFragement != null) {
//			ft.hide(doctorFragement);
//		}
//		if (personFragement != null) {
//			ft.hide(personFragement);
//		}
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.left_img:
			 finish();
			break;

		default:
			break;
		}
//		switchFragment(v.getId());
	}
}
